// pages/member/rankingListSecond/rankingListSecond.js
var app = getApp();
Page({

  /**
	 * 页面的初始数据
	 */
  data: {
    language: '',
    mailLanguage: '',
    mailFullReturnTitle: '',
    mailFullReturnAmount: '',
    mailFullReturnName: '',
    order_amount: 0.00,
    return_amount: 0.00,
    status_name: '',
    each_return_rate: 0,
    return_mode: '',
    not_return: 0.00,
    order_sn: '',
    created_at: '',
    finish_time: '',
    id: '',
    new:false
  },

  /**
	 * 生命周期函数--监听页面加载
	 */
  onLoad: function(options) {
    this.setData({
      id: options.id
    });
    if(options.new){
      this.setData({
        new : true
      })
    }
    this.initMailLanguage();
    this.getData();
  },

  /**
	 * 生命周期函数--监听页面初次渲染完成
	 */
  onReady: function() {
    let language = wx.getStorageSync('langIndex');
    this.setData({ 'language': language.en});
  },

  /**
	 * 生命周期函数--监听页面显示
	 */
  onShow: function() {},

  /**
	 * 生命周期函数--监听页面隐藏
	 */
  onHide: function() {},

  /**
	 * 生命周期函数--监听页面卸载
	 */
  onUnload: function() {},

  /**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
  onPullDownRefresh: function() {},

  /**
	 * 页面上拉触底事件的处理函数
	 */
  onReachBottom: function() {},

  /**
	 * 用户点击右上角分享
	 */
  onShareAppMessage: function() {},
  initMailLanguage() {
    let mailLanguage;
    mailLanguage = wx.getStorageSync('yz_basic_info').lang;
    let mailFullReturnTitle = app.setMailLanguage('赠送详情', this.data.new ? mailLanguage?.full_reward?.return_detail : mailLanguage?.full_return?.return_detail);
    let mailFullReturnAmount = app.setMailLanguage('已赠送金额', this.data.new ? mailLanguage?.full_reward?.return_amount:mailLanguage?.full_return?.return_amount);
    let mailFullReturnName = app.setMailLanguage('赠送', this.data.new ? mailLanguage?.full_reward?.return_name:mailLanguage?.full_return?.return_name);
    this.setData({
      mailLanguage,
      mailFullReturnTitle,
      mailFullReturnAmount,
      mailFullReturnName
    });
    wx.setNavigationBarTitle({
      title: mailFullReturnTitle ? mailFullReturnTitle : ''
    });
  },
  // 获取数据
  getData() {
    console.log("plugin.full-return.frontend.detail.index".replace(/full-return/g,'full-reward'),this.data.new)
    let urlStr = app.getNetAddresss(this.data.new?"plugin.full-return.frontend.detail.index".replace(/full-return/g,'full-reward'):'plugin.full-return.frontend.detail.index');
    urlStr += "&log_id=" + this.options.id;
    app._getNetWork({
      url: urlStr,
      success: (res) => {
        let resdata = res.data;
        if (resdata.result === 1) {
          this.setData({
            amount: resdata.data.item.amount,
            ratio: resdata.data.item.info.ratio,
            info: resdata.data.item.info,
            turnover: resdata.data.item.info.turnover,
            unit_price: resdata.data.item.info.unit_price,
            amount_total: resdata.data.item.info.amount_total,
            amount_surplus: resdata.data.item.info.amount_surplus,
            created_at: resdata.data.item.created_at,
          });
          if(this.data.new){
            // wx.setNavigationBarTitle({
            //   title: ,
            // })
          }
        } else {
          wx.showToast({
            title: resdata.msg,
            icon: 'none'
          });
        }
      },
      fail: function(res) {
        console.log(res);
      }
    });
  },
});
